<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			*{
				margin: 0px;
				padding: 0px;
			}
			body{
				height: 2000px;
			}
			div{
				border: 1px solid aqua;
				width:100%;
				height: 500px;
				overflow: auto;
			}
		</style>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
	</head>
	<body>
		<div style="height:50px"></div>
		<div id="adv">
			<form id="form" method="get" action="">
				<input type="search" name="sear" palceholder="请输入要搜索的内容"/>
				<input type="submit" value="GO"/>
			</form>
		</div>
		<script>			
			$(function(){
				var yuan = $("#adv").offset().top; //原始高度
				$(window).scroll(function(){
					var gundong = $(this).scrollTop(); //滚动时的动态高度	
					if(gundong>= yuan) {
						$("#adv").css({"position":"fixed","top":0});
					}else {
						$("#adv").css("position","static");
					}
				})
			})
		</script>
	</body>
</html>
